package org.example.springdemo2;


import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class RequestController {
    @RequestMapping("/Hello")
    public String say(){
        return "Hello,SpringMvc";
    }

    @RequestMapping("/r1")
    public String hello(String name){
        return "返回name:" +name;
    }

    @RequestMapping("/r2")
    public String r2(Integer age){
        return "返回age:" +age;
    }

    //传基础类型和包装类型的区别，不传的情况下包装类型有null值，基础类型会直接报错
    @RequestMapping("/r3")
    public String r3(int age){
        return "返回age:" +age;
    }


//    @RequestMapping("/r4")
//    public String r4(@RequestParam("name") String userName) {
//        return "返回name:" +userName;
//    }

    @RequestMapping("/r5")
    public String r5(@RequestParam(required = false) List<String> list){
        return "返回list：" +list;
    }

    @RequestMapping("/r6")
    public String r6(@RequestBody Student student) {
        return "返回student:" +student;
    }

    //url中读取参数
    @RequestMapping("/article/{articleId}")
    public String r7(@PathVariable("articleId") Integer articleId){
        return "收到articleId:" +articleId;
    }

}
